﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Login : GetTogether.Studio.Web.UI.Page
{
    protected new string Error;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Form.Count > 0)
        {
            string signUsername = Request.Form["sign-username"];
            string signPassword = Request.Form["sign-password"];
            if (string.IsNullOrEmpty(signUsername) || string.IsNullOrEmpty(signPassword))
            {
                Error = "Please input username or passowrd";
            }
            Error = GetTogether.Studio.Profile.Util.Sign(CurrentSession, signUsername, signPassword);
            if (string.IsNullOrEmpty(Error))
            {
                if (!string.IsNullOrEmpty(Request.Form["auto-sign-url"]))
                    Response.Redirect(Request.Form["auto-sign-url"]);
                else
                    Response.Redirect("~/");
            }
        }
        if (!string.IsNullOrEmpty(Request["sign-out"]))
        {
            Session.Abandon();
            Response.Redirect("Login.aspx");
        }
    }
}